package com.derbysoft.synxisadapter.commons.model;


import javax.persistence.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Entity
public class ReservationLog extends Base{
    @ManyToOne(fetch = FetchType.LAZY)
    private Reservation reservation;

    @Enumerated(EnumType.STRING)
    @Column(length = 30, nullable = false)
    private OperationType operationType;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "reservationLog")
    private List<ReservationDetail> reservationDetails = new ArrayList<ReservationDetail>();

    public Reservation getReservation() {
        return reservation;
    }

    public void setReservation(Reservation reservation) {
        this.reservation = reservation;
    }

    public OperationType getOperationType() {
        return operationType;
    }

    public void setOperationType(OperationType operationType) {
        this.operationType = operationType;
    }

    public void appendDetail(ReservationDetail detail) {
        reservationDetails.add(detail);
    }

    public List<ReservationDetail> getReservationDetails() {
        return Collections.unmodifiableList(reservationDetails);
    }
}
